home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6236 < prev    next >
Encoding:
Text File  |  1996-08-05  |  795 b   |  32 lines

  1. Newsgroups: comp.lang.c++
  2. Path: hearst.acc.Virginia.EDU!maxwell!gcl8a
  3. From: gcl8a@Virginia.EDU (Gregory Carl Lewin)
  4. Subject: Re: More ?'s re: copy ctor
  5. Message-ID: <DMn8B8.yJ@Virginia.EDU>
  6. Organization: University of Virginia
  7. References: <DMD0Kq.LHx@Virginia.EDU>
  8. Date: Mon, 12 Feb 1996 03:28:19 GMT
  9.  
  10. oops!  A syntax error in my note makes the question confusing.
  11. What I meant to say is:
  12.  
  13. foo(Base2* b2) {...}
  14.  
  15. will not except:
  16.  
  17. Derived d;
  18. foo(&d);
  19.  
  20. I get a "Cannot convert from type..." error.  However, if foo
  21. is a member function of one of the classes, the error is not
  22. given:
  23.  
  24. Base2::foo(Base2* b) {...}
  25. Derived::foo(Derived* d) {Base2::foo(d); ...}    //OK!
  26.  
  27. Further, an explicit cast prevents the error, but that seems
  28. odd-why shouldn't the comiler make the cast automatically?
  29.  
  30. Greg Lewin
  31. .
  32.